<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <title>Add Bars</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
        <script src="../resources/js/admin.js"></script>
        <link rel="stylesheet" type="text/css" href="../resources/css/admin.css">
    </head>
    <body>
        <script>
            $(document).ready(function() {
                 $.when(getClientInfo()).then(
                    function(location){
                        
                    }
                )
                $inputField = $("#postal-no");
                $outputField = $("#city");
                $inputField.keyup(function(){
                    if($inputField.val().match(/\d{4}/)) {
                        $.getJSON("http://adressesok.posten.no/api/v1/postal_codes.json?postal_code=" + $inputField.val() + "&callback=?",
                        function(data){
                            $outputField.val(data["postal_codes"][0].city);
                        });
                    } else{
                        $outputField.text("");
                    }
                });
            });
        </script>
        <table id="new-bar-grid">
            <tr>
                <th>Bar Name</th>
                <th>Country</th>
                <th>Postal No.</th>
                <th>City</th>
                <th>Address</th>
                <th>CC</th>
                <th>Beer Price</th>
                <th>Description</th>
                <th>Age Limit</th>
            </tr>
            <tr id="row-0">
                <td><input type="text" id="name" name="name" autofocus></td>
                <td><select disabled id="country" name="country"><option value="Norway">Norway</option></select></td>
                <td><input type="text" id="postal-no" name="postal-no"></td>
                <td><input disabled type="text" id="city" name="city"></td>
                <td><input type="text" id="address" name="address"></td>
                <td><input type="number" id="cc" name="cc" value='0'></td>
                <td><input type="number" id="beer-price" name="beer-price"></td>
                <td><textarea id="description" name="description"></textarea></td>
                <td><input type="number" id="age-limit" name="age-limit"></td>
                <td>
                    <div id="button-wrapper">
                        <input id="add-row-btn" class="button" type="button" onclick="addBarToGrid('new-bar-grid');" title="Add row">
                        <input id="reset-btn" class="button" type="button" onclick="reset('new-bar-grid');" title="Reset">
                        <input id="run-sql-btn" class="button" type="button" onclick="" title="Run SQL">
                    </div>
                </td>
            </tr>
        </table>
    </body>
</html>
